package s47.dqj.dao;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import s47.dqj.bean.DepartmentType;

/**
 * 2.科室种类表
 * @author Administrator
 *
 */
@Repository("departmentTypeDaoImpl")
public class DepartmentTypeDaoImpl extends HibernateDaoSupport implements DepartmentTypeDaoInf{
	
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DepartmentTypeDaoInf#setSupperSessionFactory(org.hibernate.SessionFactory)
	 */
	@Override
	@Resource(name="sessionFactory")
	public void setSupperSessionFactory(SessionFactory sessionFactory){
		super.setSessionFactory(sessionFactory);
	}
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DepartmentTypeDaoInf#findAll()
	 */
	@Override
	public List<DepartmentType> findAll(){
		String hql="from DepartmentType";
		return getHibernateTemplate().find(hql);
	}
	
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DepartmentTypeDaoInf#findObjectById(s47.dqj.bean.DepartmentType)
	 */
	@Override
	public DepartmentType findObjectById(DepartmentType departmentType){
		return getHibernateTemplate().get(DepartmentType.class, departmentType.getDtid());
	}
	
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DepartmentTypeDaoInf#findObjectByDtname(s47.dqj.bean.DepartmentType)
	 */
	@Override
	public DepartmentType findObjectByDtid(DepartmentType departmentType){
		return getHibernateTemplate().get(DepartmentType.class, departmentType.getDtid());
	}
	
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DepartmentTypeDaoInf#findObjectByDtnameSimple(s47.dqj.bean.DepartmentType)
	 */
	@Override
	public List<DepartmentType> findObjectByDtnameSimple(DepartmentType departmentType){
		String hql="from DepartmentType as dt where dt.dtnameSimple='"+departmentType.getDtnameSimple()+"'";
		return getHibernateTemplate().find(hql);
	} 
	
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DepartmentTypeDaoInf#save(s47.dqj.bean.DepartmentType)
	 */
	@Override
	public void save(DepartmentType departmentType){
		getHibernateTemplate().save(departmentType);
	}
	
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DepartmentTypeDaoInf#update(s47.dqj.bean.DepartmentType)
	 */
	@Override
	public void update(DepartmentType departmentType){
		getHibernateTemplate().update(departmentType);
	}
	
	/* (non-Javadoc)
	 * @see s47.dqj.dao.DepartmentTypeDaoInf#delect(s47.dqj.bean.DepartmentType)
	 */
	@Override
	public void delect(DepartmentType departmentType){
		getHibernateTemplate().delete(departmentType);
	}
}
